package mainFragment.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.xuegengwang.xuegengwang.R;

import java.util.ArrayList;

import mainFragment.bean.CollegeIndexBean;

/**
 * Created by Administrator on 2017/3/15.
 */

public class CollegeIntroduceAdapter extends BaseAdapter {

    private ArrayList<CollegeIndexBean.MajorListBean> arrayList;
    private Context context;

    public CollegeIntroduceAdapter(Context context, ArrayList<CollegeIndexBean.MajorListBean> arrayList) {
        this.arrayList = arrayList;
        this.context = context;
    }

    @Override
    public int getCount() {
        return arrayList.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MyHolder myHolder;
        if (convertView == null) {
            myHolder = new MyHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.college_introduce_item, null);
            myHolder.averageWage = (TextView) convertView.findViewById(R.id.college_introduce_item_average_wage);
            myHolder.employmentRate = (TextView) convertView.findViewById(R.id.college_introduce_item_employment_rate);
            myHolder.name = (TextView) convertView.findViewById(R.id.college_introduce_item_name);
            convertView.setTag(myHolder);
        } else {
            myHolder = (MyHolder) convertView.getTag();
        }
        myHolder.name.setText(arrayList.get(position).getMajor());
        myHolder.employmentRate.setText(arrayList.get(position).getEmploy_rate());
        myHolder.averageWage.setText(arrayList.get(position).getSalary());
        return convertView;
    }

    class MyHolder {
        TextView name;
        TextView employmentRate;
        TextView averageWage;
    }
}
